package cn.concat;

/**
 * @author: lizemin
 * @version: 1.0
 */
public class ConcatTest {
    //这是一个main方法,是程序的入口
    public static void main(String[] args) {
        //1.+可以拼接null，和数字，但是concat只能拼接字符串
        String str1 = "s1";
        System.out.println(str1 + 100);
        System.out.println(100 + str1);
        System.out.println(false + str1);
        System.out.println(2.35 + str1);
        //s1100
        //100s1

        System.out.println("------------------");
        String str2 = "s2";
        str2 = str2.concat("a").concat("bc");
        str2 = str2.concat("sdf").concat("bc");
        System.out.println(str2);
        //s2abc


        System.out.println("------------------");
        String str3 = "s3";
        System.out.println(str3 + null);
        System.out.println(null + str3);
        //s3null
        //nulls3

        System.out.println("------------------");
        String str4 = null;
        System.out.println(str4.concat("a"));
        System.out.println("a".concat(str4));
        //java.lang.NullPointerException




    }
}
